/*
 * main_server.cpp
 *
 *  Created on: Jan 12, 2009
 *      Author: tandaica0612
 */
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string>
#include <iostream>
#include <stdio.h>
using namespace std;
/*
int main(int argc, char *argv[]) {
	 //
	 // Co che' hoat. dong. cua? server theo co che' TCP :
	 // 1.socket()
	 // 2.bind()
	 // 3.listen()
	 // 4.accept()
	 // 5.read()
	 // 6.write()
	 // 7.close()
	 // Chu'y' , buoc' 5,6 co' the? lap. vo han.
	 //
	int server_sock = socket(AF_INET,SOCK_STREAM,0);
	sockaddr_in server_addr,client_addr;
	//
	server_addr.sin_family = AF_INET;
	server_addr.sin_addr.s_addr = INADDR_ANY;
	server_addr.sin_port = htons(6324);
	//
	bind(server_sock,(struct sockaddr*)&server_addr,sizeof(server_addr));
	//
	listen(server_sock,5);
	int client_len = sizeof(client_addr);
	int client_sock = accept(server_sock,(struct sockaddr*)&client_addr,(socklen_t*)&client_len);
	//
	int sizebuf = 500;
	char buf[sizebuf+1];
	int isok = recv(client_sock,buf,sizebuf,0);
	if(isok != -1){
		cout <<"client >" << buf << endl;
		//
		string ser_response_msg = "Da nhan. duoc. '"+(string)buf+"'";
		send(client_sock,ser_response_msg.c_str(),ser_response_msg.size(),0);
	}
}
**/
